<template>
  <div class="recommend">
    <Card>
      <!-- <span></span> 此处可以修改插槽内容 -->
    </Card>
    <ul>
      <li v-for="(item, index) in recommendList" :key="index">
        <h2>
          <!-- 图片懒加载 v-lazy -->
          <img v-lazy="item.imgUrl" atl="" />
        </h2>
        <div class="introduce">
          <h3>{{ item.name }}</h3>
          <p>{{ item.content }}</p>
          <div class="price">
            <span>￥</span>
            <b>{{ item.price }}</b>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import Card from "@/components/home/Card.vue";
export default {
  name: "Recommend",
  props: {
    recommendList: Array,
  },
  components: {
    Card,
  },
  data() {
    return {
      // recommendList: [
      //   {
      //     id: 1,
      //     name: "龙井1号铁罐250g",
      //     content: "新鲜爽口 口粮首选",
      //     price: "68",
      //     imgUrl: require("@/assets/image/recommend-01.jpeg"),
      //   },
      //   {
      //     id: 2,
      //     name: "龙井1号铁罐250g",
      //     content: "新鲜爽口 口粮首选",
      //     price: "68",
      //     imgUrl: require("@/assets/image/recommend-01.jpeg"),
      //   },
      // ],
    };
  },
};
</script>

<style scoped lang="less">
.recommend {
  width: 100%;
  font-size: 0.4rem;
  background-color: #fff;
  // margin:0.25rem 0;
  padding: 0.2rem 0;

  ul {
    width: 95%;
    margin: 0 auto;

    li {
      width: 100%;
      position: relative;
      width: 100%;
      margin-bottom: 0.125rem;
      background-color: #f3f3f3;
      border-radius: 0.1rem;

      h2 {
        margin-left: 0.3125rem;
        width: 40%;
        text-align: center;

        img {
          width: 100%;
          border-radius: 0.375rem;
          padding-top: 0.15rem;
        }
        //懒加载样式
        img[lazy="loading"] {
          background-color: #f7f7f7;
        }
      }
      .introduce {
        position: absolute;
        top: 0.3125rem;
        right: 0;
        margin-right: 0.3125rem;
        display: flex;
        flex-direction: column;

        .price {
          text-align: right;
          color: #e11;
          margin-top: 1.25rem;
          font-size: 0.625rem;
        }
      }
    }
  }
}
</style>
